//
//  HttpsRequestTool.m
//  ABSallRec
//
//  Created by 我演示 on 2019/10/31.
//  Copyright © 2019 Jerry-Fu. All rights reserved.
//

#import "HttpsControlTool.h"
#import <UIKit/UIKit.h>

@implementation HttpsControlTool


+(instancetype)sharedControlTool{
 
 static HttpsControlTool *_shareControlTool = nil ;
    static dispatch_once_t onceToken ;
    
    dispatch_once(&onceToken, ^{
        
        if (_shareControlTool == nil) {
            _shareControlTool =  [[self alloc] init];
                 NSLog(@"单利测试");
        
        }

   
    });
    return _shareControlTool;
}

-(void )listenConntect{
 //1:创建网络监听者
   AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager manager];
   //2:获取网络状态
   /*
    AFNetworkReachabilityStatusUnknown          = 未知网络，
    AFNetworkReachabilityStatusNotReachable     = 没有联网
    AFNetworkReachabilityStatusReachableViaWWAN = 蜂窝数据
    AFNetworkReachabilityStatusReachableViaWiFi = 无线网
    */
   [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
       
       switch (status) {
           case AFNetworkReachabilityStatusUnknown:
               NSLog(@"未知网络");
               break;
               
        /** 提示无网络状态链接跳转*/
           case AFNetworkReachabilityStatusNotReachable:
                {
                    UIWindow *window = [UIApplication sharedApplication].keyWindow;
                    
                    FSLNormalAlertView *alertView = [[FSLNormalAlertView alloc] initWithTitle:@"dian" andLeftString:@"hah" rightString:@"koo"];
                    alertView.frame = window.frame ;
                    alertView.makeSureBlock = ^{
                    };
                    [window addSubview:alertView];
                    
                }
               
               
               NSLog(@"没有联网");
               break;
           case AFNetworkReachabilityStatusReachableViaWWAN:
               NSLog(@"蜂窝数据");
               break;
           case AFNetworkReachabilityStatusReachableViaWiFi:
               NSLog(@"无线网");
               break;
           default:
               break;
       }
   }];
   
    
   //开启网络监听
   [manager startMonitoring];
}

@end
